using System.Collections.Generic;
using System;

namespace HEFramework
{
    public class DataTable<T> : DataTableBase
    {
        private Dictionary<int, T> dic;

        public DataTable()
        {
        }

        public override void Init(string _Name, Type _type, object _dic)
        {
            base.Init(_Name, _type, _dic);
            this.dic = _dic as Dictionary<int, T>;
        }

        public T[] GetAllData()
        {
            T[] data = new T[dic.Count];
            dic.Values.CopyTo(data, 0);
            return data;
        }

        public T GetData(int _id)
        {
            dic.TryGetValue(_id, out T Data);
            return Data;
        }

        public bool ContainsData(int _id)
        {
            return dic.ContainsKey(_id);
        }
    }
}